package com.socialcoco.controller;


import com.socialcoco.entity.Seckillproduct;
import com.socialcoco.entity.Tgood;
import com.socialcoco.respone.BaseResponse;
import com.socialcoco.respone.ResultUtils;
import com.socialcoco.serviceImpl.SeckillproductServiceImpl;
import com.socialcoco.serviceImpl.TgoodServiceImpl;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.concurrent.ExecutionException;

@RestController
@Slf4j
@RequestMapping("/socialcoco/user")
public class seckillController {

    @Autowired
    private SeckillproductServiceImpl seckillproductService;

    @Autowired
    TgoodServiceImpl service;



    @GetMapping("/spikeProduct")
    public BaseResponse<Object> spikeProduct(){
        List<Seckillproduct> list = seckillproductService.list();
        return ResultUtils.success(list);
    }
    @GetMapping("/spikeProducts")
    public BaseResponse<Object> spikeProducts(){
        List<Tgood> list = service.list();
        return ResultUtils.success(list);
    }
    @GetMapping("/spikeProduct/{uid}/{sid}")
    public BaseResponse<Object> kill(@PathVariable String sid,@PathVariable String uid) throws InterruptedException, ExecutionException {
        String s = seckillproductService.killProduct(uid, sid);
        if("exist".equals(s)){
            return ResultUtils.success("exist");
        }
        return ResultUtils.success("ok");
    }
    @GetMapping("/killIndex/{uid}/{sid}")
    public BaseResponse<Object> killIndex(@PathVariable String sid,@PathVariable String uid) throws InterruptedException, ExecutionException {
        String s = service.killProduct(uid, sid);
        if("exist".equals(s)){
            return ResultUtils.success("exist");
        }
        return ResultUtils.success("ok");
    }

//    @ApiOperation("管理员上架积分商城商品")
//    @PostMapping

}
